<?php
#基础函数
include_once('_path.php');

#通用函数
include_once(_CONST_LOCAL_INCLUDE_PATH."common.php");

#db
include_once(_CONST_LOCAL_INCLUDE_PATH."database.class.php");
$database = new Database($db_vars);

#权限
if (!is_logined()) {
header("Location:"._CONST_WEB_URL."login-personal.html");
exit;
}

$action = trim($_GET['action']);

 if ($action == "edit.do") {

     #得到post的值
$name = trim($_REQUEST['name']);
	$quote['name'] = string_sql($name);
$sex = trim($_REQUEST['sex']);
	$quote['sex'] = string_sql($sex);
$birthday = trim($_REQUEST['birthday']);
	$quote['birthday'] = string_sql($birthday);
$nation = trim($_REQUEST['nation']);
	$quote['nation'] = string_sql($nation);
$company = trim($_REQUEST['company']);
	$quote['company'] = string_sql($company);
$job = trim($_REQUEST['job']);
	$quote['job'] = string_sql($job);
$phone = trim($_REQUEST['phone']);
	$quote['phone'] = string_sql($phone);
$tel = trim($_REQUEST['tel']);
	$quote['tel'] = string_sql($tel);
$email = trim($_REQUEST['email']);
	$quote['email'] = string_sql($email);
$qq = trim($_REQUEST['qq']);
	$quote['qq'] = string_sql($qq);
$address = trim($_REQUEST['address']);
	$quote['address'] = string_sql($address);
$zipcode = trim($_REQUEST['zipcode']);
	$quote['zipcode'] = string_sql($zipcode);

        verify_field("name", "姓名", "empty");
	verify_field("tel", "手机", "empty");
        verify_field("email", "电子邮箱", "email");

	if (!count($error_strs)) {
		$sql = "UPDATE members_info SET name = ".$quote['name'].
                ", sex = ".$quote['sex'].", birthday = ".$quote['birthday'].", nation = ".$quote['nation'].", company = ".$quote['company'].
                ", job = ".$quote['job'].", phone = ".$quote['phone'].", tel = ".$quote['tel'].", email = ".$quote['email'].
                ", qq = ".$quote['qq'].", address = ".$quote['address'].", zipcode = ".$quote['zipcode'].
                " WHERE id = ".$_SESSION['user_id'].";";
               $database->execute($sql);
		$action="";
	} else {
		$action = "edit.view";
	}
 }
$rs = $database->queryFirst("SELECT * FROM members_info WHERE id=".$_SESSION['user_id'] );
?>
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
	<title>用户中心-Haiersi•GL-海尔斯管历健康服务网</title>
	<link href="../media/css/reset.css" rel="stylesheet" type="text/css"/>
	<link href="../media/css/base.css" rel="stylesheet" type="text/css"/>
	<script type="text/javascript" src="../media/js/jquery-1.4.2.min.js"></script>
                   <script type="text/javascript" src="../media/js/jquery.validate.min.js"></script>
        <script type="text/javascript">
jQuery.noConflict();
jQuery(function($) {
  $('#form').validate({
  });
});
</script>
</head>
<body id="uc">
<div class="wrapper">
	<div class="header clearfix">
		<a  class="logo fl" href="../index.html"><h1>Hesgl</h1></a>
		<ul class="nav fr clearfix">
			<li class="cur"><a href="../index.html">首页</a></li>
			<li><a href="../about-us.html">关于我们</a></li>
			<li><a href="../services.html">我们的服务</a></li>
			<li><a href="../approach.html">我们的方法</a></li>
			<li><a href="../health.html">企业健康管理</a></li>
			<li><a href="../news.html">新闻</a></li>
			<li class="last"><a href="../contacts.html">联系我们</a></li>
		</ul>
	</div>

    <div class="content clearfix">
    	<div class="user-info">欢迎<em><?=$_SESSION['name']?></em> ［<a href="../logout.php">退出登录</a>］</div>
        <div class="main">
        		<div class="traininc-nav-list">
        		<ul>
        			<li class="selected"><a href="p-home.html">基本信息</a></li>
        			<li><a href="p-file.html">文件上传</a></li>
        			<li><a href="p-feedback.html">留言管理</a></li>
        		</ul>
        	</div>
        	<div class="box-con">
	        	<table class="table-view">
	        		<tr>
	        			<td class="title">您的编号</td>
	        			<td><?=$rs['id']?></td>
	        		</tr>
	        		<tr>
	        			<td class="title">您的卡号</td>
	        			<td><?=$rs['card']?></td>
	        		</tr>
	        		<tr>
	        			<td class="title">您所属网点</td>
	        			<td><?=$rs['region']?></td>
	        		</tr>
	        	</table>
	        	<br />
	        	<h3>个人详细信息</h3>
                       <?php
                       if($action=="edit.view"){
                       ?>
                        <form action="p-home.php?action=edit.do" method="post" id="form" name="form">
        		<table class="table-view">
        			<tr>
        				<td class="title">姓名</td>
                                        <td><input type="text" size="30" name="name" value="<?=$rs['name']?>" class="required"> > <?= show_field_error('name') ?></td>
        				<td class="title">性别</td>
                                        <td>
                                                    <select name="sex">
                                                        <option value="男" <?=iif($rs['sex']=='男', "selected='selected'")?>>男</option>
                                                        <option value="女" <?=iif($rs['sex']=='女', "selected='selected'")?>>女</option>
                                                        <option value="无" <?=iif($rs['sex']=='无', "selected='selected'")?>>无</option>
                                                    </select>
                                        </td>
        			</tr>
        			<tr>
        				<td class="title">出生年月</td>
                                        <td><input type="text" size="30" name="birthday" value="<?=$rs['birthday']?>" ></td>
        				<td class="title">民族</td>
        				<td><input type="text" size="30" name="nation" value="<?=$rs['nation']?>" ></td>
        			</tr>
        			<tr>
        				<td class="title">单位</td>
                                        <td><input type="text" size="30" name="company" value="<?=$rs['company'];?>" ></td>
        				<td class="title">职务</td>
                                        <td><input type="text" size="30" name="job" value="<?=$rs['job'];?>" ></td>
        			</tr>
        			<tr>
        				<td class="title">座机</td>
                                        <td><input type="text" size="30" name="phone" value="<?=$rs['phone'];?>" ></td>
        				<td class="title">手机</td>
                                        <td><input type="text" size="30" name="tel" value="<?=$rs['tel'];?>" ></td>
        			</tr>
        			<tr>
        				<td class="title">电子邮箱</td>
                                        <td><input type="text" size="30" name="email" value="<?=$rs['email'];?>" class="required email"> > <?= show_field_error('email') ?></td>
        				<td class="title">qq</td>
                                        <td><input type="text" size="30" name="qq" value="<?=$rs['qq'];?>" ></td>
        			</tr>
        			<tr>
        				<td class="title">家庭地址</td>
                                        <td><input type="text" size="30" name="address" value="<?=$rs['address'];?>" ></td>
        				<td class="title">邮编</td>
                                        <td><input type="text" size="30" name="zipcode" value="<?=$rs['zipcode'];?>" ></td>
        			</tr>
        			<tr>
        				<td class="title"> </td>
                                        <td colspan="3"><input type="submit" name="" value="提交" class="btnA" /></td>
        			</tr>
        		</table>
                        </form>
                        <?php
                       }else{
                        ?>
                         <form action="p-home.php?action=edit.view" method="post" id="form" name="form">
        		<table class="table-view">
        			<tr>
        				<td class="title">姓名</td>
        				<td><?=$rs['name']?></td>
        				<td class="title">性别</td>
        				<td><?=$rs['sex']?></td>
        			</tr>
        			<tr>
        				<td class="title">出生年月</td>
        				<td><?=$rs['birthday']?></td>
        				<td class="title">民族</td>
        				<td><?=$rs['nation'];?></td>
        			</tr>
        			<tr>
        				<td class="title">单位</td>
        				<td><?=$rs['company'];?></td>
        				<td class="title">职务</td>
        				<td><?=$rs['job'];?></td>
        			</tr>
        			<tr>
        				<td class="title">座机</td>
        				<td><?=$rs['phone'];?></td>
        				<td class="title">手机</td>
        				<td>＋<?=$rs['tel'];?></td>
        			</tr>
        			<tr>
        				<td class="title">电子邮箱</td>
        				<td><?=$rs['email'];?></td>
        				<td class="title">qq</td>
        				<td><?=$rs['qq'];?></td>
        			</tr>
        			<tr>
        				<td class="title">家庭地址</td>
        				<td><?=$rs['address'];?></td>
        				<td class="title">邮编</td>
        				<td><?=$rs['zipcode'];?></td>
        			</tr>
        			<tr>
        				<td class="title"> </td>
                                        <td colspan="3"><input type="submit" name="" value="修改" class="btnA" /></td>
        			</tr>
        		</table>
                        </form>
                        <?php
                       }
                        ?>
        	</div>
        </div>

    </div>
	<div class="footer">
	    <p class="copyright">Copyright © 2011 Hesgl.com All Rights Reserved</p>
	</div>
</div>
</body>
</html>